{extend name="common/__base" /}
{block name="body"}
<form class="layui-form layui-form-pane">
    <input type="hidden" name="id" value="{$adminInfo.id}">
    <div class="layui-form-item">
        <label for="role" class="layui-form-label">角色</label>
        <div class="layui-input-block">
            <select name="role" id="role">
                {volist name="adminInfo.role_list" id="vo"}
                <option value="{$vo.id}" {if condition="$vo.id eq $adminInfo.role_id"}selected{/if}>{$vo.title}</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label for="username" class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="username" name="username" value="{$adminInfo.username}" disabled placeholder="请输入用户名">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="password" class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="password" class="layui-input" id="password" name="password" placeholder="不填则是不修改">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="name" class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="name" name="name" value="{$adminInfo.name}" placeholder="姓名">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="phone" class="layui-form-label">电话</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="phone" name="phone" value="{$adminInfo.phone}" placeholder="电话">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="qq" class="layui-form-label">QQ</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="qq" name="qq" value="{$adminInfo.qq}" placeholder="QQ">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="status" class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="checkbox" name="status" value="1" id="status" lay-skin="switch" lay-text="正常|禁用" {if condition="$adminInfo.status eq 1"}checked{/if}>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" type="submit" id="submit">编辑</button>
            <button class="layui-btn layui-btn-primary" type="reset" >重置</button>
        </div>
    </div>
</form>
{/block}

{block name="js"}
<script>
    var form = layui.form;

    // 表单提交
    $("#submit").click(function () {
        $.ajax({
            url: "{:url('admin/admin/editAdmin')}",
            type: "post",
            data: $("form").serialize(),
            dataType: "json",
            success: function (ret) {
                if (ret.code == 1) {
                    layer.msg(ret.msg, {time: 2000}, function () {
                        parent.location.reload();
                    });
                } else {
                    layer.msg(ret.msg);
                }
            }
        });
        return false;
    });
</script>
{/block}